home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / kaffe-0.2 / kaffe / classMethod.h < prev    next >
C/C++ Source or Header  |  1996-02-14  |  3KB  |  124 lines

  1. /*
  2.  * classMethod.h
  3.  * Class, method and field tables.
  4.  *
  5.  * Copyright (c) 1996 Systems Architecture Research Centre,
  6.  *           City University, London, UK.
  7.  *
  8.  * See the file "license.terms" for information on usage and redistribution
  9.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  10.  *
  11.  * Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
  12.  */
  13.  
  14. #ifndef __classmethod_h
  15. #define __classmethod_h
  16.  
  17. #include "gtypes.h"
  18. #include "access.h"
  19. #include "constants.h"
  20. #include "object.h"
  21.  
  22. #define    MAXMETHOD        64
  23.  
  24. /* Class state */
  25. #define    CSTATE_OK        0
  26. #define    CSTATE_NEEDINIT        1
  27. #define    CSTATE_DOINGINIT    2
  28.  
  29. struct _constants;
  30. struct _methods;
  31. struct _fields;
  32. struct _methodTable;
  33. struct _exception;
  34.  
  35. typedef struct _classes {
  36.     object            head;        /* A class is an object too */
  37.     struct _classes*    next;
  38.     char*            name;
  39.     char*            sig;
  40.     int            accflags;
  41.     char*            supername;
  42.     struct _classes*    superclass;
  43.     struct _constants*    constants;
  44.     struct _methods*    methodList;
  45.     struct _fields*        fieldList;
  46.     int            fsize;
  47.     struct _fields*        staticFieldList;
  48.     int            sfsize;
  49.     struct _methodTable*    mtable;
  50.     int*            staticFields;
  51.     struct _classes**    interface;
  52.     int            interface_len;
  53.     struct _classes*    nextInit;
  54.     struct _classes*    prevInit;
  55.     int            state;
  56.     bool            final;
  57. } classes;
  58.  
  59. typedef struct _methods {
  60.     struct _methods*    next;
  61.     strpair*        pair;
  62.     accessFlags        accflags;
  63.     char*            code;
  64.     int            codelen;
  65.     struct _instn*        insn;
  66.     nativecode*        ncode;
  67.     nativecode*        ncode_end;
  68.     struct _constants*    constants;
  69.     struct _exception*    exception_table;
  70.     int            exception_table_len;
  71.     struct _methods*    exception_next;
  72.     int            stacksz;
  73.     int            localsz;
  74.     int            ins;
  75.     int            outs;
  76.     classes*        class;
  77.     struct _tableswitch*    tableswitches;
  78.     struct _lookupswitch*    lookupswitches;
  79. } methods;
  80.  
  81. typedef struct _methodTable {
  82.     classes*        class;
  83.     struct {
  84.         strpair*    tag;
  85.         void*        method;
  86.     } m[MAXMETHOD];
  87. } methodTable;
  88.  
  89. #define    MTABLE_CLASS        0
  90. #define    MTABLE_METHODOFFSET    4
  91. #define    MTABLE_METHODSIZE    8
  92. #define    MTABLE_TAG        0
  93. #define    MTABLE_METHOD        4
  94.  
  95. typedef struct _fields {
  96.     struct _fields*        next;
  97.     char*            name;
  98.     char*            sig;
  99.     accessFlags        accflags;
  100.     classes*        class;
  101.     int            size;
  102.     int            offset;
  103. } fields;
  104.  
  105. #define    CLASSHASHSZ        128
  106. #define    MAXSIG            256
  107.  
  108. struct _Code;
  109. struct _method_info;
  110.  
  111. classes*    addClass(constIndex, constIndex, u2, struct _constants*);
  112. methods*    addMethod(classes*, struct _method_info*);
  113. void         addMethodCode(methods*, struct _Code*);
  114. classes*    lookupClass(char*);
  115. classes*    simpleLookupClass(char*);
  116. classes*    lookupArray(char*);
  117. fields*        lookupClassField(char*, char*, bool);
  118. void        countInsAndOuts(char*, int*, int*);
  119. int        sizeofSig(char**);
  120. void        establishMethod(methods*);
  121. void        addInterfaces(classes*, int, classes**);
  122.  
  123. #endif
  124.